package novel.manager.service.utils;

import novel.manager.pojo.spider.NovelSiteEnum;
import novel.manager.service.iface.spider.chapter.IChapterSpider;
import novel.manager.service.impl.spider.chapter.BxwxChapterSpider;
import novel.manager.service.impl.spider.chapter.DefaultChapterSpider;

public final class ChapterSpiderFactory {
	private ChapterSpiderFactory() {}
	
	/**
	 * 通过给定的url，返回一个实现了IChapterSpider接口的实现类DefaultChapterSpider或BxwxChapterSpider
	 */
	//url:章节列表页面
	public static IChapterSpider getChapterSpider(String url) {
		NovelSiteEnum novelSiteEnum = NovelSiteEnum.getEnumByUrl(url);
		IChapterSpider chapterSpider = null;
		switch (novelSiteEnum) {
		case Bxwx :
			chapterSpider = new BxwxChapterSpider(); break;
		case DingDianXiaoShuo:
		case BiQuGe:
		case KanShuZhong :
		chapterSpider = new DefaultChapterSpider(); break;
		}
		return chapterSpider;
	}
}
